package com.erpoa.mapper;

import com.erpoa.entity.ErpAccessoriesData;
import com.erpoa.utils.StringUtil;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author:0xOO
 * @Date: 2018/9/26 0026
 * @Time: 15:20
 */
@Mapper
public interface ImaFileMapper {

   /* @Select( "select count(*) from  ${ds}.tc_sqds_file where tc_sqds01=#{sqId}"+
    "and tc_sqds10= #{workshop} and tc_sqds14 = #{purchase}"+
    "and tc_sqds09 LIKE CONCAT(CONCAT('%', #{v_gmisc}), '%')")*/
    int count(@Param("sqId") Integer sqId, @Param("ds") String ds, @Param("workshop") String workshop, @Param("purchase") String purchase, @Param("v_gmisc")  String v_gmisc);

    List<Map<String,Object>> queryList();

//    @Select("select * from user where id = #{sqId}")
    String sumMonth(@Param("workshop")String workshop, @Param("purchase")String purchase,@Param("month")Integer month);
    String qrySmyDesc(@Param("smyslip")String smyslip,@Param("ds")String ds) ;

    HashMap<String, Object> selectOaDeptByCode(@Param("userID")String userID);

    List<Map<String, Object>> querySqDsById(@Param("sqId") Integer sqId, @Param("ds") String ds,
                                            @Param("workshop") String workshop, @Param("purchase") String purchase, @Param("v_gmisc") String v_gmisc);

    HashMap<String, Object> querySqDtById(@Param("sqId")Integer sqId, @Param("ds")String ds);

    void insertByOA(@Param("sqId") Integer sqId, @Param("ds") String ds, @Param("workshop") String workshop,
                    @Param("purchase") String purchase, @Param("createWorkflowRequest") String createWorkflowRequest,
                    @Param("tcSqds18") String tcSqds18, @Param("tcSqds16") String tcSqds16);


  //  @Select(" select TC_OADEPTID,TC_OADEPTNAME,TC_ERPDEPTID,TC_ERPDEPTNAME,TC_FENJIHAO from TC_OADEPT_FILE where TC_ERPDEPTID = #{deptid} ")
    HashMap<String, Object> selectDeptByCode(@Param("deptid")String deptid);

    String queryCheById(@Param("deptid")String deptid);

    List<Map<String,Object>> querySqDsByIdColipu(@Param("sqId") Integer sqId, @Param("ds") String ds);

    int countcpmla(@Param("tc_sqds17") String tc_sqds17, @Param("ds") String ds);

    List<String> selectcountcpmla(@Param("tc_sqds17") String tc_sqds17, @Param("ds") String ds);

    String selectByrequestid(@Param("tc_sqds17")String tc_sqds17);

    @Select("SELECT distinct REQUESTID REQUESTID ,decode(SSGS, '0', 'DS1', '1', 'DS2', '4', 'DS4', 'DS22') SSGS  FROM erpoa.V_OAERP_FLCGlog  where  trunc(COMMITDATE) = trunc(sysdate)   GROUP BY REQUESTID ,SSGS ")
        //@Select("SELECT distinct REQUESTID REQUESTID ,decode(SSGS, '0', 'DS1', '1', 'DS2', '4', 'DS4', 'DS22') SSGS  FROM erpoa.V_OAERP_FLCGlog  where   REQUESTID='1352584617'   GROUP BY REQUESTID ,SSGS ")
    List<Map<String,Object>> selectByToday();

    @Select("SELECT * " +
            " FROM erpoa.t_erpoa_uf_log where instr(lcmc,'生产辅料申购单')=1 and trunc(bdate) = trunc(sysdate)     ")
    List<Map<String,Object>> selectuflogByToday();

    @Select(" select tc_sqdt01,tc_sqdt02, nvl(email,'45@mg-pen.com') GEN02 from ( select tc_sqdt01,tc_sqdt02,gen01   from tc_sqdt_file,tc_sqds_file,gen_file   " +
            " where tc_sqdt01=tc_sqds01 and tc_sqdtuser =gen01 and  instr(tc_sqds17,#{requestid})>0 and rownum=1" +
            " )   left join v_oaerp_hrmrd@OAPROD on loginid =gen01  ")
    Map selectiUserInfo(@Param("requestid") String requestid);

    /**
     * @return
     */
    List<ErpAccessoriesData> selectErpAccessoriesData();

    /**
     * @param hrno
     * @return
     */
    String selectNameByHrno(@Param("hrno") String hrno);

    /**
     * @return
     */
    List<String> selectsqdsName();

    /**
     * @return
     */
    List<String> selectcgName();

    /**
     *
     * @param sqId
     * @param ds
     * @param workshop
     * @param purchase
     * @param v_gmisc
     * @return
     */
    List<Map<String, Object>> querySqDsByIdEquipment(@Param("sqId") Integer sqId, @Param("ds") String ds,
                                                     @Param("workshop") String workshop, @Param("purchase") String purchase, @Param("v_gmisc") String v_gmisc);

    @Select("  select nvl(email,'45@mg-pen.com') email from v_oaerp_hrmrd@OAPROD  where loginid=#{lcmc}  ")
    StringUtil selectEmailBylcmc(@Param("lcmc") String lcmc);
}
